package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    ShoppingCart list(ShoppingCart shoppingCart);
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumber(ShoppingCart shoppingCartlist);

    void insert(ShoppingCart shoppingCart);

    /**
     * 查看购物车
     * @param userId
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> getShoppingCart(Long userId);

    /**
     * 删除购物车中 一个商品
     * @param shoppingCart
     */
    void deleteOne(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id =#{userId}")
    void deleteAll(Long userId);
}
